function UI_CreateLabel ( text, x, y, w, h, parent )
	local ele = createElement ( "UI_Label" )
	setElementParent ( ele, parent or getResourceDynamicElementRoot ( sourceResource or getThisResource ( ) ) )

	setElementData ( ele, "UI_Text", text )
	setElementData ( ele, "UI_X", x )
	setElementData ( ele, "UI_Y", y )
	setElementData ( ele, "UI_Width", w )
	setElementData ( ele, "UI_Height", h )
	setElementData ( ele, "UI_Alpha", 255 )
	setElementData ( ele, "UI_RGB", { ["Red"] = 255, ["Green"] = 255, ["Blue"] = 255 } )
	setElementData ( ele, "UI_Font", "default-bold" )
	setElementData ( ele, "UI_FontSize", 1 )
	setElementData ( ele, "UI_ColorCoded", false )
	setElementData ( ele, "UI_HorizontalAlign", "left" )
	setElementData ( ele, "UI_VerticalAlign", "top" )
	setElementData ( ele, "UI_EventMouseState", false )
	
	setElementData ( ele, "UI_RenderTarget", dxCreateRenderTarget ( w > 1 and w or 1, h > 1 and h or 1, true ) )

	if ( parent ) then
		if ( not UI_RenderParent[parent] ) then UI_RenderParent[parent] = {} end
		table.insert ( UI_RenderParent[parent], ele )
	else
		table.insert ( UI_Render, ele )
	end
	
	return ele
end

function UI_LabelSetHorizontalAlign ( ele, align )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_Label" ) then
		if ( align == "left" or align == "center" or align == "right" ) then
			if ( setElementData ( ele, "UI_HorizontalAlign", align ) ) then
				return true
			end
		end
	end
	return false
end

function UI_LabelSetVerticalAlign ( ele, align )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_Label" ) then
		if ( align == "top" or align == "center" or align == "bottom" ) then
			if ( setElementData ( ele, "UI_VerticalAlign", align ) ) then
				return true
			end
		end
	end
	return false
end

function UI_ImageGeneratorLabel ( ele )
	local Text = getElementData ( ele, "UI_Text" ) or " "
	local X = getElementData ( ele, "UI_X" ) or 0
	local Y = getElementData ( ele, "UI_Y" ) or 0
	local Width = getElementData ( ele, "UI_Width" ) or 0
	local Height = getElementData ( ele, "UI_Height" ) or 0
	local RGB = getElementData ( ele, "UI_RGB" ) or { ["Red"] = 255, ["Green"] = 255, ["Blue"] = 255 }
	local Font = getElementData ( ele, "UI_Font" ) or "default-bold"
	local FontSize = getElementData ( ele, "UI_FontSize" ) or 1
	if ( isElement ( Font ) and getElementType ( Font ) == "UI_Font" ) then
		Font = getElementData ( Font, "UI_Font" )
	end
	local Colored = getElementData ( ele, "UI_ColorCoded" ) or false
	local HorizontalAlign = getElementData ( ele, "UI_HorizontalAlign" ) or "left"
	local VerticalAlign = getElementData ( ele, "UI_VerticalAlign" ) or "top"
	local MouseState = getElementData ( ele, "UI_EventMouseState" ) or false
	local RenderTarget = getElementData ( ele, "UI_RenderTarget" )

	local AlignX = 0
	local AlignY = 0

	if ( HorizontalAlign == "center" ) then
		AlignX = Width / 2
	elseif ( HorizontalAlign == "right" ) then
		AlignX = Width
	end

	if ( VerticalAlign == "center" ) then
		AlignY = Height / 2
	elseif ( VerticalAlign == "bottom" ) then
		AlignY = Height
	end

	dxSetRenderTarget ( RenderTarget, true )
	dxDrawText ( Text, AlignX, AlignY, tocolor ( RGB["Red"], RGB["Green"], RGB["Blue"], 255 ), FontSize, Font, HorizontalAlign, VerticalAlign, _, Colored )
	dxSetRenderTarget ( )
	return RenderTarget or nil
end